package Fileint_;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Fileintostream_ {
    public static void main(String[] args) {

    }
    @Test
    public void file(){
        FileInputStream fileInputStream=null;
        FileOutputStream fileOutputStream=null;
        byte[] b=new byte[1024];
        int n=0;
        try {
            fileInputStream=new FileInputStream("d:\\d1ae-icuacsa3949374.jpg");
            fileOutputStream=new FileOutputStream("d:\\next4.jpg");
            while ((n=fileInputStream.read(b))!=-1){
                fileOutputStream.write(b,0,n);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if (fileInputStream!=null) {
                    fileInputStream.close();
                }
                if(fileOutputStream!=null){
                fileOutputStream.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
    }
}
